/*
 *  This file is part of WWWPal.
 *
 *  Copyright (C) 2003  Dr. John Punin, Department of Computer Science
 *  Rensselaer Polytechnic Institute
 *
 *  WWWPal is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  WWWPal is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with Foobar; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#include "LOGR_gen_info.h"

WebGenInfoPtr
new_gen_info_node(void)
{
  WebGenInfoPtr wgi = (WebGenInfoPtr)calloc(1, sizeof(WebGenInfoStruct));
  if(!wgi) {
      fprintf(stderr,"Out of Memory new_gen_info_node\n");
      abort();
  }
  return wgi;
}

void
delete_gen_info_node(WebGenInfoPtr wgi)
{	
    if(!wgi) return;
    free(wgi); wgi = NULL;
}

void
LOGR_set_gen_info_naccesses(WebGenInfoPtr wgi,long num)
{
  if(!wgi) return;
  wgi->naccesses = num;
}

void
LOGR_add_gen_info_naccesses(WebGenInfoPtr wgi,long num)
{
  if(!wgi) return;
  wgi->naccesses += num;
}

void
LOGR_inc_gen_info_naccesses(WebGenInfoPtr wgi)
{
  if(!wgi) return;
  wgi->naccesses++;
}

void *
LOGR_get_gen_info_context(WebGenInfoPtr wgi)
{
  if(!wgi) return NULL;
  return wgi->info;
}

void
LOGR_set_gen_info_context(WebGenInfoPtr wgi,void *info)
{
  if(!wgi) return;
  wgi->info = info;
}

long
LOGR_get_gen_info_naccesses(WebGenInfoPtr wgi)
{
  if(!wgi) return 0;
  return wgi->naccesses;
}


void
LOGR_set_gen_info_sizebytes(WebGenInfoPtr wgi,double num)
{
  if(!wgi) return;
  wgi->sbytes = num;
}

void
LOGR_add_gen_info_sizebytes(WebGenInfoPtr wgi,double num)
{
  if(!wgi) return;
  wgi->sbytes += num;
}

double
LOGR_get_gen_info_sizebytes(WebGenInfoPtr wgi)
{
  if(!wgi) return 0;
  return wgi->sbytes;
}


void
LOGR_set_gen_info_npages(WebGenInfoPtr wgi,long num)
{
  if(!wgi) return;
  wgi->npages = num;
}

void
LOGR_add_gen_info_npages(WebGenInfoPtr wgi,long num)
{
  if(!wgi) return;
  wgi->npages += num;
}

void
LOGR_inc_gen_info_npages(WebGenInfoPtr wgi)
{
  if(!wgi) return;
  wgi->npages++;
}

long
LOGR_get_gen_info_npages(WebGenInfoPtr wgi)
{
  if(!wgi) return 0;
  return wgi->npages;
}

int
LOGR_is_access_gen_info_lower(WebGenInfoPtr u, WebGenInfoPtr v)
{
  return (u->naccesses < v->naccesses);
}

int
LOGR_is_access_gen_info_bigger(WebGenInfoPtr u,WebGenInfoPtr v)
{
  return(u->naccesses > v->naccesses);
}

int
LOGR_is_npages_gen_info_lower(WebGenInfoPtr u, WebGenInfoPtr v)
{
  return (u->npages < v->npages);
}

int
LOGR_is_npages_gen_info_bigger(WebGenInfoPtr u,WebGenInfoPtr v)
{
  return(u->npages > v->npages);
}

int
LOGR_is_context_gen_info_lower(WebGenInfoPtr u, WebGenInfoPtr v)
{
  return ((int)u->info < (int)v->info);
}

int
LOGR_is_context_gen_info_bigger(WebGenInfoPtr u,WebGenInfoPtr v)
{
  return((int)u->info > (int)v->info);
}



